
/**\file gr_streamsignature.h Stream signature
*
*/
#pragma once

#include<map>
#include<vector>
#include<cstdint>
#include<typeinfo>

namespace gr{

enum StreamType
{
    STREAM_FLOAT4
};

size_t streamTypeSize(StreamType type);

bool isCompatibleType(StreamType type);

/** Contains signature of single channel of stream. */
struct StreamChannelInfo
{
    StreamType  channelType;
    size_t      offset;     //> At what offset does the sample data start
    std::string name;
};

StreamChannelInfo streamChannelInfo(StreamType channelType, uint32_t offset, const char* name);

class StreamSignature
{
public:

    typedef std::vector<StreamChannelInfo> SignatureArray;

    size_t          sampleSize_;
    SignatureArray  channels_;

    StreamSignature():sampleSize_(0){}
    
    void add(StreamType type, const char* name)
    {
        size_t offset = sampleSize_;
        sampleSize_ += streamTypeSize(type);
        channels_.push_back(streamChannelInfo(type, offset, name));
    }

    SignatureArray::iterator begin(){return channels_.begin();}

    SignatureArray::iterator end(){return channels_.end();}

    size_t sampleSize(){return sampleSize_;}
    
    /** Return pointer to offset of specified channel or null if name not found. */
    const size_t* offsetOfChannel(const std::string& name);

    /** Return pointer to type of specified channel or null if name not found. */
    const StreamType* typeOfChannel(const std::string& name);

    const size_t sizeOfChannel(const std::string& name);

};




}
